﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Windows.Forms;
using pos.entity;
using NHibernate.Criterion;

using System.Data;

using System.IO;
using System.Threading;

namespace pos
{
    static class Program
    {
        public static Thread thread;
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {


           

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            
            try
            {
               
                thread = new Thread(ThreadFunction);
                //  thread.IsBackground = true;
                thread.Start();

                
             
               payFrmLogin dlg = new payFrmLogin();
             //   dlg.TopLevel = true;
               DialogResult rs = dlg.ShowDialog();
             
                if (rs == DialogResult.Yes)
                {
                    try
                    {
                        if (pos.entity.consts.groupID == "admin" || pos.entity.consts.groupID == "stocker")
                            Application.Run(new MainMDIParent());
                        else
                            Application.Run(new PayFrm(null));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }


              
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
              
                return;
            }

            
            
           
            //Application.Run(new MainMDIParent());
            
            

            
        }
        static void ThreadFunction()
        {
            try
            {
            pos.entity.SpringContext.init();

            //   Application.Run(new WebServiceForm());
            //   return;

            t_setting t = new t_setting();
            //DataSet dataset = t.query("", "");
            IList list = t.List(null);
            foreach (Setting r in list)
            {
                t.Init(r);
                if (consts.SettingPara[t.id] == null)
                    consts.SettingPara.Add(t.id, t.value);
            }
               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
              
                return;
            }

            
        }
    }
}
